/**
 * PresentWelDC.java  2012-3-21 上午10:21:49
 * 
 * Copyright 2012 Founder. All rights reserved.
 */
package com.audiocn.poster;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

/**
 * Class description goes here.
 *
 * @version 1.0
 * @author wang-wei
 */
public class PresentWelDC extends Activity{
	private SharedPreferences sp;
	private Intent intent;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        intent = new Intent(PresentWelDC.this, MsgListDC.class);
        
        sp = getSharedPreferences("notebook_authentication", Context.MODE_PRIVATE);
        if(sp.getString("keys", null) !=null && sp.getString("keys", null).equals("privateKey")){
        	startActivity(intent);
        	finish();
        }else{
        	aboutDialog();
        }
    }
    
    private void aboutDialog(){
		AlertDialog.Builder builder = new AlertDialog.Builder(this);  
        builder.setTitle("礼品传送界面");  
        builder.setMessage("欢迎使用 礼品接力\n版本：1.0\n" +
        		"支持Android OS 2.1或者以上\n2012年3月\n作者：王 炜\n");
        builder.setIcon(R.drawable.icon);
        builder.setPositiveButton("确定", new OnClickListener() {
        	@Override
        	public void onClick(DialogInterface dialog, int which) {
        		(sp.edit()).putString("keys", "privateKey").commit();
                startActivity(intent);
                finish();
        	}
        });
        builder.setNegativeButton("取消", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				finish();
			}
		});
        builder.show();
	}
}
